<style type="text/css">
	#wrap {
		width: 94%;
		height: auto;
		overflow: hidden;
		margin: 0px 10px;
		padding: 0px 10px;
	}
	#wrap dl{
		margin: 10px 0px;
		border: 1px solid #EFF4F5;
		height: auto;
		overflow: hidden;
	}
	#wrap dl dt{
		display: block;
		height: 36px;
		line-height: 36px;
		background: #ECF2F3;
		text-indent: 10px;
	}
	#wrap dl dt strong{
		font-size: 16px;
		color: #61aefa;
	}

	#wrap dl dd {
		padding: 10px;
		float: left;
	}
</style>
<script type="text/javascript">
	$(function(){
		$('input[level=1]').click(function(){
			var inputs = $(this).parents('dl').find('input');
			console.log(inputs.val());
			$(this).attr('checked') ? inputs.attr('checked','checked') : inputs.removeAttr('checked');
		});
		$('input[level=2]').click(function(){
			var input = $(this).parent().parents('dl').find('dt input');
			var dd_inputs = $(this).parent().parents('dl').find('dd input:checked');
			if (dd_inputs.length >= 1) {
				input.attr('checked','checked');
			} else {
				input.removeAttr('checked');
			}

		})

	})
</script>
<div class="pageContent">
	<form method="post" action="auth/set_access/<?php echo $rid ?>"onsubmit="return validateCallback(this,navTabAjaxDone);">
		<div id="wrap" level="1">
			<?php foreach ($nodes as $key => $value): ?>
			<dl>
				<dt>
					<input type="checkbox" name="rules[]" value="<?php echo $value['nid'] ?>" <?php echo $value['access']?"checked='checked'":'' ?> level="1"/><strong>&nbsp;<?php echo $value['title']; ?></strong>
				</dt>
				<?php foreach ($value['child'] as $k => $v): ?>
					<dd>
						<input type="checkbox" name="rules[]" value="<?php echo $v['nid'] ?>" <?php echo $v['access']?"checked=checked":'' ?> level="2"/><span>&nbsp;<?php echo $v['title'] ?></span>
					</dd>
				<?php endforeach ?>
			</dl>
			<?php endforeach ?>
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<input type="hidden" name="rid" value="<?php echo $rid ?>">
				<input type="hidden" name="post" value="true">
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>
